package com.crs.mapper;

import com.crs.entity.CreditEvent;
import com.crs.entity.CreditRule;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CreditMapper {

    /**
     * 通过传递的事件类型来判断属于哪个事件
     * @param eventType
     * @return
     */
    @Select("select * from credit_rule where event_type = #{eventType}")
    CreditRule findByEventType(Integer eventType);

    /**
     * 向信用事件表中插入事件
     * @param creditEvent
     */
    @Insert("insert into credit_event (user_id, event_type, change_value," +
            " borrow_id, description,create_time) values (#{userId},#{eventType},#{changeValue}," +
            "#{borrowId},#{description},#{createTime})")
    void insert(CreditEvent creditEvent);
}
